import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

//密钥对生成 https://uutool.cn/rsa-generate/

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK42g+HOIV1lacJcaMMxrsmPuRz1r8ZR\n' +
    'k1BmVoqoE/JmhNDYQ4aT+ojSo1tsxK/dd8eCvjF8mu0xk4lf9nTnOD0CAwEAAQ==';

const privateKey = 'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEArjaD4c4hXWVpwlxo\n' +
    'wzGuyY+5HPWvxlGTUGZWiqgT8maE0NhDhpP6iNKjW2zEr913x4K+MXya7TGTiV/2\n' +
    'dOc4PQIDAQABAkBGMYT16H4dCY2RWHaFn3ETmas2de+68odur61S9OIEmouWS+cy\n' +
    'QMWv1/OjXh3wBJG8dbB6VHUja9rcgy5fd1CBAiEA37aJ70QoNv5vrMz8IYXuZTIS\n' +
    'jAKZpEF3nxte6Ys3220CIQDHWxxZDBKIpgogE3Rd7CdmzUki7GQLehlURMMcl7p+\n' +
    'EQIhAIqwSoDnuxqk0CzLg79wnWNlEHR2JDPdVkBwIn4cjctdAiEAsDp8jsM7Rwzw\n' +
    'enZ4Mebm1du3QWYS8opXBcVbbVU7iOECIA7L82qaq1te4ugM77whBOWOVJJfCGwd\n' +
    'ujUDAY6otGcS';

//加密
export function encrypt(txt){
    const encryptor = new JSEncrypt();
    encryptor.setPublicKey(publicKey); // 设置公钥
    return encryptor.encrypt(txt); // 对数据进行加密
}

//解密
export function decrypt(txt){
    const encryptor = new JSEncrypt();
    encryptor.setPrivateKey(privateKey); // 设置私钥
    return encryptor.decrypt(txt); // 对数据进行解密
}
